import greenfoot.*;  // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)

/**
 * Write a description of class Energia here.
 * 
 * @author (your name) 
 * @version (a version number or a date)
 */
public class Energia extends Puntaje
{
    /**
     * Act - do whatever the Energia wants to do. This method is called whenever
     * the 'Act' or 'Run' button gets pressed in the environment.
     */  
    private int numeroAux;//numero que determina cuando se aumenta la vida si la energia esta completa
    
    public void act() 
    {
        // Add your action code here.
        this.getImage().scale(escala,50);
        if(escala==150){
            World aux=getWorld();
            Vida vida=((StickmanWorld)aux).getVida();
          if(numeroAux==100){vida.aumenta();numeroAux=0;}
           numeroAux++;
        }
        reduceEnergia();
      
    }

    public Energia(){
        this.getImage().scale(150,50);
        escala=150;
        numero=0;
        reduce=false;
        numeroAux=0;
    }  

    public void reduceEnergia(){    
        // Add your action code here.
        if(reduce==true){
        if(numero==100 && escala!=1){
            escala=escala-10;
            this.getImage().scale(escala,50);
           
            if(escala==10){
             World aux=getWorld();
            ((StickmanWorld)aux).ReduceVida(1);
            
            }
            numero=0;
        }
        if(escala==10){
            World aux=getWorld();
           ((StickmanWorld)aux).ReduceVida(1);
        }else{ numero++;}
        }

    }
   
    public void reduce(int reduccion){
    if(reduccion==1)
    reduce=true;
    if(reduccion==2)
    reduce=false;
    
    }
    public void aumenta(){     
      if(escala<=140){escala=escala+10;}else{  
          World aux=getWorld();
            ((StickmanWorld)aux).creaLetrero(1,2);}
    }
    public int getEscala(){return escala;}
    
    
}
